package com.pap.product.product.controller;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.pap.base.controller.BaseController;
import com.pap.obj.vo.response.ResponseVO;
import com.pap.product.agent.item.dto.ItemCheckDTO;
import com.pap.product.agent.product.IProductDetailAgent;
import com.pap.product.agent.product.dto.formula.ProductDetailDatabaseDTO;
import com.pap.product.agent.product.dto.formuladefine.ProductItemDTO;
import com.pap.product.product.auto.entity.ProductDetail;

@RestController
@RequestMapping("/v1/product/productdetail")
public class ProductDetailController extends BaseController<ProductDetail, IProductDetailAgent> {

	private static Logger logger  =  LoggerFactory.getLogger(ProductDetailController.class);
	
	@Resource(name = "productDetailAgent")
	@Override
	public void setService(IProductDetailAgent agent) {
		super.service = agent;
	}
	
	/**
	 * 查询某一个产品下面包含的融资项目信息，融资项目信息只归属于此产品
	 * 用来查询显示此产品下面所包含的融资项目信息
	 * @param clientLicenseId
	 * @param loginUserId
	 * @param productId
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/selectitemforshow/{productId}")
	public ResponseVO<ItemCheckDTO> selectAllItemForShow(@RequestHeader(value = "clientLicenseId", defaultValue = "-1") String clientLicenseId,
			@RequestHeader(value = "loginUserId", defaultValue = "-1") String loginUserId,
			@PathVariable String productId) {
		List<ItemCheckDTO> list = service.selectProductDetailForList(clientLicenseId, productId);
		return ResponseVO.successdatas(list, null);
	}
	
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/selectproductdetailitem/{productId}")
	public ResponseVO<ItemCheckDTO> selectProductDetailItem(@RequestHeader(value = "clientLicenseId", defaultValue = "-1") String clientLicenseId,
			@RequestHeader(value = "loginUserId", defaultValue = "-1") String loginUserId,
			@PathVariable String productId) {
		List<ProductItemDTO> list = service.selectProductDetailItem(clientLicenseId, productId);
		return ResponseVO.successdatas(list, null);
	}
	
}
